#!/bin/bash
#
# create perf graphs for the following comparisons:
# - django vs apache
# - error vs normal message
# - limited vs normal resources
# - increased vs normal db size
#
# Note: varnish caching active for all queries
#

# start by generating default stats
ab -n 100 -c 10 -g django.dat http://localhost:8008/app/
ab -n 100 -c 10 -g apache.dat http://localhost:8008/

# error messages
ab -n 100 -c 10 -g error.dat http://localhost/

# increase db size
sh ../feedback_webapp/generate_data.sh

# test with new db
ab -n 100 -c 10 -g db.dat http://localhost:8008/app/happy/

# limit resources
# use max 1M memory
echo 1M > /cgroup/memory/apache/memory.max_limit_in_bytes
# use ~10% cpu
echo 100 > /cgroup/cpu/apache/cpu.shares

# test with limited resources
ab -n 100 -c 10 -g limited.dat http://localhost:8008/app/happy/

# undo resource limitations
echo 1024M > /cgroup/memory/apache/memory.max_limit_in_bytes
echo 1000 > /cgroup/cpu/apache/cpu.shares

# varnish caching
# re-run test
#ab -n 100 -c 10 -g varnish.dat http://localhost/app/

# generate graphs
gnuplot djangoVapache.p
gnuplot error.p
gnuplot db.p
gnuplot limited.p

# open result in browser
midori result.html



